package com.ruoyi.buss.report.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.buss.utils.DateUtilss;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.buss.report.mapper.ReportZhkhfxLsbMapper;
import com.ruoyi.buss.report.domain.ReportZhkhfxLsb;
import com.ruoyi.buss.report.service.IReportZhkhfxLsbService;

/**
 * 支行客户分析Service业务层处理
 * 
 * @author sxy
 * @date 2021-07-16
 */
@Service
public class ReportZhkhfxLsbServiceImpl implements IReportZhkhfxLsbService 
{
    @Autowired
    private ReportZhkhfxLsbMapper reportZhkhfxLsbMapper;

    /**
     * 查询支行客户分析
     * 
     * @param sjrq 支行客户分析ID
     * @return 支行客户分析
     */
    @Override
    public ReportZhkhfxLsb selectReportZhkhfxLsbById(String sjrq)
    {
        return reportZhkhfxLsbMapper.selectReportZhkhfxLsbById(sjrq);
    }

    /**
     * 查询支行客户分析列表
     * 
     * @param reportZhkhfxLsb 支行客户分析
     * @return 支行客户分析
     */
    @Override
    public List<ReportZhkhfxLsb> selectReportZhkhfxLsbList(ReportZhkhfxLsb reportZhkhfxLsb)
    {
        return reportZhkhfxLsbMapper.selectReportZhkhfxLsbList(reportZhkhfxLsb);
    }

    /**
     * 新增支行客户分析
     * 
     * @param reportZhkhfxLsb 支行客户分析
     * @return 结果
     */
    @Override
    public int insertReportZhkhfxLsb(ReportZhkhfxLsb reportZhkhfxLsb)
    {
        return reportZhkhfxLsbMapper.insertReportZhkhfxLsb(reportZhkhfxLsb);
    }

    /**
     * 修改支行客户分析
     * 
     * @param reportZhkhfxLsb 支行客户分析
     * @return 结果
     */
    @Override
    public int updateReportZhkhfxLsb(ReportZhkhfxLsb reportZhkhfxLsb)
    {
        return reportZhkhfxLsbMapper.updateReportZhkhfxLsb(reportZhkhfxLsb);
    }

    /**
     * 批量删除支行客户分析
     * 
     * @param sjrqs 需要删除的支行客户分析ID
     * @return 结果
     */
    @Override
    public int deleteReportZhkhfxLsbByIds(String[] sjrqs)
    {
        return reportZhkhfxLsbMapper.deleteReportZhkhfxLsbByIds(sjrqs);
    }

    /**
     * 删除支行客户分析信息
     * 
     * @param sjrq 支行客户分析ID
     * @return 结果
     */
    @Override
    public int deleteReportZhkhfxLsbById(String sjrq)
    {
        return reportZhkhfxLsbMapper.deleteReportZhkhfxLsbById(sjrq);
    }

    @Override
    public List<ReportZhkhfxLsb> zhkhqsfx(ReportZhkhfxLsb reportZhkhfxLsb, LoginUser userInfo) {
        // 获取当前角色ID的集合
        
        List<ReportZhkhfxLsb> doList = new ArrayList<ReportZhkhfxLsb>();

        /**
         * 判断数据日期是否为近3年4个季度以及当年每个月月末
         */
        ArrayList<String> sjrqs = DateUtilss.getThreeYearFourQuarterAndMonth();
        if (!StringUtils.isEmpty(reportZhkhfxLsb.getSjrq())) {
            if ("9999".equals(reportZhkhfxLsb.getSjrq())) {
                reportZhkhfxLsb.setSjrq("");
            }
            sjrqs = new ArrayList<String>();
            String sjrq = reportZhkhfxLsb.getSjrq();
            sjrq = sjrq.replace("-", "");
            sjrqs.add(sjrq);
        }

        reportZhkhfxLsb.setSjrqs(sjrqs);
        doList = reportZhkhfxLsbMapper.zhkhqsfx(reportZhkhfxLsb);

        return doList;
    }
}
